Data sharing is an important phenomenon in the day-to-day systems having a number of peripherals connected to a processor. In order to facilitate transfer of data from one peripheral to another the data is routed via the processor or a memory element. FIG. 1 is a block diagram depicting a system having at least two devices 10 and 11 that share data through a Random Access Memory (RAM) 13. The device 10 can be a slow communication link that uses a Dynamic Memory Access (DMA) Controller 12 while the device 11 can be a typical Complex Instruction Set Computing (CISC) architecture. The device 10 uses the RAM 13 as a means to share data with the device 11, as it has no dedicated First-In First-Out (FIFO) for sharing data.
The first device 10, 11 accessing the RAM 13 may release control of the RAM 13 in between while writing bytes into it. In such a situation, if the second device 11, 10 reads the shared buffer in the RAM 13, it will read the buffer which is partially updated. Hence there is a need for a method to protect the atomicity of such shared data, where the term “atomicity” in this context relates to an operation, which in the present example is the writing of bytes in to a shared buffer in the RAM 13, that must be performed entirely before these bytes are read from the shared buffer. Those skilled in the art will understand the use of the term atomicity in the context of the present invention.
Conventional FIFO memory interfaces are often used to temporarily store data sequentially that is shared between two or more processes, for e.g. a slow communication link and the CPU as shown in FIG. 2. FIFO interfaces are typically employed to accommodate processes that operate asynchronously as described in U.S. Pat. No. 4,151,609.
The communication link 20 transfers data to the CPU 22 using a FIFO buffer 21. To quote an example, a sending process in the communications link 20 writes to the buffer 21, filling the buffer to a particular threshold, and then signals the receiving CPU 22 to read the filled buffer. This significantly increases the waiting time for the processes to read/write if both processes work at different rates. Further, if a process releases the buffer 21 for it to be accessed by any other process before completing the transfer of a set of data, then atomicity of the data is lost as the second process gets access to data that is not updated completely.
Suppose the CPU 22 is processing data, which consists of multiple bytes, it will take approximately 3 to 6 CPU clock cycles per byte (CISC architecture). Hence to write N bytes it requires N*x (x ranging from 3 to 6 depending on the architecture of the CPU) clock cycles. If in the course of this processing, same data is read by an I2C communications link, a peripheral, using a DMA controller then the atomicity of data read will be lost (i.e. it will read some old bytes and some processed bytes). One method of protecting corruption of shared data would be to disable the DMA during the writing of N bytes, which would result in a waiting time of N*x clock cycles for any DMA requests.
Based on the foregoing, a need exists for a capability that provides efficient utilization of a shared buffer with atomicity of data maintained between read/write accesses.
The requirement for an improved architecture is due to the limitations of prior art approaches and the waiting time constraint for processes to access shared memory.